﻿<UserControl x:Class="SIEGate.UI.UserControls.MeasurementGroupUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="650" d:DesignWidth="850"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:myuc="clr-namespace:SIEGate.UI.UserControls"
             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"             
             Background="Transparent">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
        
    <StackPanel x:Name="StackPanelManageMeasurementGroup" Orientation="Vertical">

        <StackPanel.Resources>

            <Style TargetType="ListBox">
                <Setter Property="Width" Value="250" />
                <Setter Property="SelectionMode" Value="Multiple"/>
                <Setter Property="Height" Value="525" />
                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            </Style>

            <Style TargetType="Grid">
                <Setter Property="Margin" Value="5,0,5,0"/>
            </Style>

        </StackPanel.Resources>

        <ComboBox ItemsSource="{tsfBinding:Column Path=ItemsSource}" SelectedItem="{tsfBinding:Column Path=CurrentItem}" Width="250">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{tsfBinding:Column Path=Name}" TextAlignment="Left" Padding="1" />
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

        <Grid x:Name="GridDetailView" DataContext="{tsfBinding:Column Path=CurrentItem}" HorizontalAlignment="Left">
            <Grid.BindingGroup >
                <BindingGroup Name="input"/>
            </Grid.BindingGroup>
                    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
                    
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
                <TextBlock Text="Name" Style="{StaticResource RequiredLabel}"/>
                <TextBlock Style="{StaticResource RequiredMarker}" />
            </StackPanel>
            <TextBox Grid.Row="0" Grid.Column="1" Text="{tsfBinding:Column Path=Name}" MaxLength="50"/>

            <TextBlock Grid.Row="0" Grid.Column="2" Text="Description" />
            <TextBox Grid.Row="0" Grid.Column="3" Text="{tsfBinding:Column Path=Description}" TextWrapping="Wrap" Width="400"/>

        </Grid>

        <uc:DetailViewFooterUserControl DeleteCommand="{Binding DeleteCommand}" ClearCommand="{Binding ClearCommand}" SaveCommand="{Binding SaveCommand}"
            SaveEnabled="{tsfBinding:DataOperation Path=(Validation.HasError)}" HorizontalAlignment="Right" />

        <Grid DataContext="{tsfBinding:Column Path=CurrentItem}" 
                Visibility="{Binding Path=DataContext.CanDelete, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel}, Converter={StaticResource ObjectToVisibilityConverter}}">
                    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <TextBlock Grid.Column="0" Grid.Row="0" Text="Member Measurements" HorizontalAlignment="Left" FontWeight="Bold"/>
            <uc:MeasurementPagerUserControl Grid.Column="0" Grid.Row="1" Name="MemberMeasurementsPager" ItemsPerPage="22" Selectable="True" Searchable="True" ShowPageSize="False" Width="400" Height="550" VerticalAlignment="Top" Margin="0" />

            <StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Button Content="&gt;&gt;" ToolTip="Remove Measurements" Width="Auto" Margin="2" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}, Path=CanSave}" Click="RemoveMeasurementsButton_Click"/>
                <Button Content="&lt;&lt;" ToolTip="Add Measurements" Width="Auto" Margin="2" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}, Path=CanSave}" Click="AddMeasurementsButton_Click"/>
            </StackPanel>

            <TextBlock Grid.Column="2" Grid.Row="0" Text="Available Measurements" HorizontalAlignment="Left" FontWeight="Bold"/>
            <uc:MeasurementPagerUserControl Grid.Column="2" Grid.Row="1" Name="AvailableMeasurementsPager" ItemsPerPage="22" Selectable="True" Searchable="True" ShowPageSize="False" Width="400" Height="550" VerticalAlignment="Top" Margin="0" />
        </Grid>
    </StackPanel>    
</UserControl>
